package com.lgy.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lgy.download.DownloadManager;
import com.lgy.download.DownloadUtils;

@Controller
@RequestMapping("/fileDown")
public class FileController {
	@Autowired
	private DownloadManager downLoadManager;
	
	@RequestMapping("/aaa")
	public void down(HttpServletResponse response) {
		//String fileUrl = "http://182.92.105.142:8079/group1/M00/00/03/tlxpjlZEPHSAJ3buAAA54C1JGnA317.jpg";
		String fileUrl = "http://182.92.105.142:8079/group1/M00/00/06/tlxpjlZOeLmAJ7zxAF-HdjkqvzM932.apk";
		//String fileUrl = "http://photocdn.sohu.com/20151122/Img427576348.jpg";
		try {
			//web端下载
			long fileSize = DownloadUtils.getRemoteFileSize(fileUrl);
			downLoadManager.down(response, "ggg.apk", fileUrl, fileSize);
			
			//下载文件到D盘
			//String path = "D://mm.apk";
			//downLoadManager.down(path, fileUrl, downLoadManager.getRemoteFileSize(fileUrl));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
